using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class UIFloatingText : MonoBehaviour
{
	public ObjectPool textPool;

	public Text levelUpText;

	public Text killText;

	public void ShowText(string str)
	{
		Text t = textPool.GetNext<Text>();
		t.transform.SetAsLastSibling();
		t.fontSize = 20;
		t.color = Color.white;
		t.text = str;
		t.rectTransform.anchoredPosition = new Vector3(0f, 20f);
		t.DOKill();
		t.DOFade(0f, 0.5f).SetDelay(0.5f).OnComplete(delegate
		{
			if ((bool)t)
			{
				t.gameObject.SetActive(value: false);
			}
		});
		t.rectTransform.DOKill();
		t.rectTransform.DOAnchorPosY(70f, 1f).SetEase(Ease.Linear);
	}

	public void ShowLevelUp(Color color, bool isMaxLevel = false)
	{
		if (isMaxLevel)
		{
			levelUpText.text = LocalizationManager.GetTranslation("TXT_GAME_SIZE_MAX");
		}
		else
		{
			levelUpText.text = LocalizationManager.GetTranslation("TXT_GAME_SIZE_UP");
		}
		levelUpText.gameObject.SetActive(value: true);
		levelUpText.color = color;
		levelUpText.rectTransform.anchoredPosition = new Vector3(0f, 20f);
		levelUpText.DOKill();
		levelUpText.DOFade(0f, 0.3f).SetDelay(1f).OnComplete(delegate
		{
			if ((bool)levelUpText)
			{
				levelUpText.gameObject.SetActive(value: false);
			}
		});
		levelUpText.rectTransform.DOKill();
		levelUpText.rectTransform.DOAnchorPosY(90f, 1f).SetEase(Ease.OutBack);
	}

	public void ShowKill(Color color, int count, int pts)
	{
		if (count == 1)
		{
			killText.gameObject.SetActive(value: true);
			killText.rectTransform.anchoredPosition = new Vector3(0f, 20f);
		}
		killText.rectTransform.DOKill();
		killText.DOKill();
		string empty = string.Empty;
		empty = ((count > 6) ? string.Format("{0} +{1}", LocalizationManager.GetTranslation("TXT_GAME_SERIAL_KILL"), pts) : $"{LocalizationManager.GetTranslation($"TXT_GAME_KILL_{count - 1}")} +{pts}");
		killText.text = empty;
		killText.color = color;
		killText.rectTransform.localScale = Vector3.one * 0.9f;
		killText.rectTransform.DOScale(Vector3.one * 1.2f, 0.2f).SetEase(Ease.OutBack);
		killText.rectTransform.DOAnchorPosY(110f, 0.5f).SetEase(Ease.OutBack);
		killText.DOFade(0f, 0.5f).SetDelay(1f).OnComplete(delegate
		{
			if ((bool)killText)
			{
				killText.gameObject.SetActive(value: false);
			}
		});
	}
}
